package com.yztc.xiami_app.ui.activity.user;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.yztc.xiami_app.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SetActivity extends AppCompatActivity {
    private Context mContext=this;
    private AlertDialog exitDialog;
    private boolean flag=false;
    @BindView(R.id.imageview_back)
    ImageView imageviewBack;
    @BindView(R.id.layout_picture)
    LinearLayout layoutPicture;
    @BindView(R.id.mine_clip)
    ImageView mineClip;
    @BindView(R.id.layout_phone)
    LinearLayout layoutPhone;
    @BindView(R.id.mine_receive_notify)
    ImageView mineReceiveNotify;
    @BindView(R.id.layout_msg_pull)
    LinearLayout layoutMsgPull;
    @BindView(R.id.layout_about)
    LinearLayout layoutAbout;
    @BindView(R.id.activity_set)
    LinearLayout activitySet;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);
        //PushAgent.getInstance(context).onAppStart();
        //AnmaPW6bAFukAi6ViPgGX__X9hSc4B9j2HJqBpIJqum-   devicetoken
        ButterKnife.bind(this);
    }
    @OnClick({R.id.imageview_back, R.id.layout_picture, R.id.mine_clip, R.id.layout_phone, R.id.mine_receive_notify, R.id.layout_msg_pull, R.id.layout_about})
    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()) {
            case R.id.imageview_back://返回按键
                finish();
                break;
            case R.id.layout_picture:
                initDialog();
                exitDialog.show();
                break;
            case R.id.mine_clip:
                //设置高亮显示
                flag=!flag;
                if(flag){
                    mineClip.setImageResource(R.mipmap.pay_checkout_receiver_on);
                }else{
                mineClip.setImageResource(R.mipmap.pay_checkout_receiver_off);
              }
                break;
            case R.id.layout_phone:
                break;
            case R.id.mine_receive_notify:
                //设置高亮显示
                flag=!flag;
                if(flag){
                    mineReceiveNotify.setImageResource(R.mipmap.pay_checkout_receiver_on);
                }else{
                    mineReceiveNotify.setImageResource(R.mipmap.pay_checkout_receiver_off);
                }
                break;
            case R.id.layout_msg_pull:
                intent.setClass(this, LoginActivity.class);
                startActivity(intent);
                break;
            case R.id.layout_about:
                break;
        }
    }

    private void initDialog() {
        //自定义dailog
        AlertDialog.Builder dlialog=new AlertDialog.Builder(mContext)
                .setTitle("清除缓存")
                .setMessage("保留缓存可以节省网络流量，确定清除SD卡图片缓存")
                .setNegativeButton("取消",null)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(mContext, "清理完成", Toast.LENGTH_SHORT).show();
                    }
                });
        exitDialog= dlialog.create();
    }
}
